<template>
	<div class="my">
		<van-field v-model="form.Contact" label="公司名称" disabled />
		<van-field v-model="form.Mobile" type="number" label="座机" disabled />
		<van-field v-model="form.Phone" type="number" label="手机" disabled />
		<van-field v-model="form.Email" label="邮箱" disabled />

		<div class="problem">
			<div class="mb-10">问题反馈</div>
			<van-field
				style="background-color: #e8f1f8"
				v-model="Content"
				rows="3"
				type="textarea"
				placeholder="请输入反馈内容"
				class="mb-20"
			/>
			<van-uploader
				v-model="fileList"
				:max-count="2"
				@oversize="onOversize"
				:after-read="afterRead"
			>
			</van-uploader>
			<div class="btn_submit">
				<van-button type="info" @click="_submit"> 提交反馈意见 </van-button>
			</div>
		</div>
	</div>
</template>

<script>
import { Toast } from 'vant'
import { upload } from "@/api/common";
export default {
	components: {},
	data() {
		return {
			form: {},
			fileList: [],
			Images: '',
			Content: '',
			imgs: [],
		}
	},
	created() {
		this.getInfo()
	},
	methods: {
		getInfo() {
			let url = '/CommonFeedback/GetContacts' // /api/goods
			this.$axios
				.get(url)
				.then((res) => {
					this.form = res.data[0]
					// res.data.f
				})
				.catch((err) => {
					console.log('err', err)
				})
		},
		// 上传图片
		afterRead(file) {
			let params = new FormData() //创建form对象
			params.append('file', file.file)
			upload(params).then((res) => {
					res.data.forEach((item) => {
						this.imgs.push(item.FilePath)
					})
				})
				.catch((err) => {
					console.log('err', err)
				})
		},
		onOversize(file) {
			Toast('文件大小不能超过 2M')
		},
		// 提交
		_submit() {
			let url = '/CommonFeedback/Add'
			let data = {
				Content: this.Content,
				Images: this.imgs.join(';'),
			}
			this.$axios
				.post(url, data)
				.then((res) => {
					if (res.success) {
						Toast.success('提交成功')
					}
				})
				.catch((err) => {
					console.log('err', err)
				})
		},
	},
}
</script>

<style lang="less" scoped>
.my {
	height: 100vh;
	background-color: #e8f1f8;
	
}
.problem {
	margin-top: 10px;
	padding: 10px;
	background-color: #ffffff;
}
.btn_submit {
	text-align: center;
	margin-top: 30px;
}
</style>

